package com.inspsys.algorithms.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.inspsys.common.annotation.Log;
import com.inspsys.common.core.controller.BaseController;
import com.inspsys.common.core.domain.AjaxResult;
import com.inspsys.common.enums.BusinessType;
import com.inspsys.algorithms.domain.AlgorithmsDataProcessing;
import com.inspsys.algorithms.service.IAlgorithmsDataProcessingService;
import com.inspsys.common.utils.poi.ExcelUtil;
import com.inspsys.common.core.page.TableDataInfo;

/**
 * 数据处理库Controller
 * 
 * @author inspsys
 * @date 2025-01-08
 */
@RestController
@RequestMapping("/algorithms/processing")
public class AlgorithmsDataProcessingController extends BaseController
{
    @Autowired
    private IAlgorithmsDataProcessingService algorithmsDataProcessingService;

    /**
     * 查询数据处理库列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:processing:list')")
    @GetMapping("/list")
    public TableDataInfo list(AlgorithmsDataProcessing algorithmsDataProcessing)
    {
        startPage();
        List<AlgorithmsDataProcessing> list = algorithmsDataProcessingService.selectAlgorithmsDataProcessingList(algorithmsDataProcessing);
        return getDataTable(list);
    }

    /**
     * 导出数据处理库列表
     */
    @PreAuthorize("@ss.hasPermi('algorithms:processing:export')")
    @Log(title = "数据处理库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgorithmsDataProcessing algorithmsDataProcessing)
    {
        List<AlgorithmsDataProcessing> list = algorithmsDataProcessingService.selectAlgorithmsDataProcessingList(algorithmsDataProcessing);
        ExcelUtil<AlgorithmsDataProcessing> util = new ExcelUtil<AlgorithmsDataProcessing>(AlgorithmsDataProcessing.class);
        util.exportExcel(response, list, "数据处理库数据");
    }

    /**
     * 获取数据处理库详细信息
     */
    @PreAuthorize("@ss.hasPermi('algorithms:processing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(algorithmsDataProcessingService.selectAlgorithmsDataProcessingById(id));
    }

    /**
     * 新增数据处理库
     */
    @PreAuthorize("@ss.hasPermi('algorithms:processing:add')")
    @Log(title = "数据处理库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgorithmsDataProcessing algorithmsDataProcessing)
    {
        return toAjax(algorithmsDataProcessingService.insertAlgorithmsDataProcessing(algorithmsDataProcessing));
    }

    /**
     * 修改数据处理库
     */
    @PreAuthorize("@ss.hasPermi('algorithms:processing:edit')")
    @Log(title = "数据处理库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgorithmsDataProcessing algorithmsDataProcessing)
    {
        return toAjax(algorithmsDataProcessingService.updateAlgorithmsDataProcessing(algorithmsDataProcessing));
    }

    /**
     * 删除数据处理库
     */
    @PreAuthorize("@ss.hasPermi('algorithms:processing:remove')")
    @Log(title = "数据处理库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(algorithmsDataProcessingService.deleteAlgorithmsDataProcessingByIds(ids));
    }
}
